import request from '@/utils/request'

const api_name = '/library/book'

export default {
    //根据id查询图书
    findBookById(id) {
        return request({
            url: `${api_name}/findBookById/${id}`,
            method: 'get'
        })
    },
    //查询所有图书
    findAllBooks() {
        return request({
            url: `${api_name}/findAllBooks`,
            method: 'get'
        })
    },
    //条件查询图书，带分页
    findBooksByConditionPage(page, limit, searchObj) {
        return request({
            url: `${api_name}/findBooksByConditionPage/${page}/${limit}`,
            method: 'post',
            data: searchObj
        })
    },
    //保存图书
    saveBook(book) {
        return request({
            url: `${api_name}/saveBook`,
            method: 'post',
            data: book
        })
    },
    //根据id修改图书
    updateBook(book) {
        return request({
            url: `${api_name}/updateBook`,
            method: 'put',
            data: book
        })
    },
    //根据id删除图书
    deleteBookById(id) {
        return request({
            url: `${api_name}/deleteBookById/${id}`,
            method: 'delete'
        })
    },
    //批量删除图书
    deleteBatchByIds(ids) {
        return request({
            url: `${api_name}/deleteBatchByIds`,
            method: 'delete',
            data: ids
        })
    }
}
